package com.ywu.mq.standard.configuration;

import com.ywu.mq.standard.config.KafkaAppConfig;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @ClassName YwuKafkaConfiguration
 * @Description TODO
 * @Author GroundDemo
 * @Date 2025/3/27 15:04
 * @Version 1.0
 **/
@Configuration
public class YwuKafkaConfiguration {

    @Autowired
    private KafkaAppConfig appConfig;

    @Bean
    public AdminClient adminClient() {
        // 配置 Kafka AdminClient 的属性
        Properties properties = new Properties();
        properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, appConfig.getBootstrapService());
        return AdminClient.create(properties);
    }
}
